<template>
	<view class="content">
		<view>
			<button @click="getLocation">获取位置</button>
			<text>当前地址：</text>
			<view>
				{{address}}
			</view>
		</view>
	</view>
</template>

<script>
	import QQMap from '../../common/qqmap-wx-jssdk.js';
	
	export default {
		data() {
			return {
				address: '当前值',
				qqmap: null,
			}
		},
		onLoad() {  
			
		},
		methods: {
			getLocation() {
				uni.getLocation({
					success(res1) {
						console.log('res1:', res1)
						
						this.qqmap = new QQMap({
							key: 'QBSBZ-CQNEI-FDRGI-U2K2D-KS3KE-QNFFR'
						});
						this.qqmap.reverseGeocoder({
							location: {
								latitude: res1.latitude, 
								longitude: res1.longitude
							},
							success: function(res) {
								console.log(res.result);
								this.address = res.result.address
								console.log('当前地址：' + this.address)
							},
							// fail: (error) => {
							// 	console.error(error);
							// },
							// complete: (res) => {
							// 	console.log(res);
							// }
						})
					}
				})
			},
		}
	}
</script>

<style>
</style>
